#pragma once
#ifndef __SCRIPT__EDITOR__COMPILER__HH__
#define __SCRIPT__EDITOR__COMPILER__HH__

#include "ScriptEditorPrereqs.h"
#include "LitScriptEngine.h"

namespace Lit
{
	namespace Editor
	{
		class ScriptCompiler
		{

		public:
			typedef boost::function<void( ScriptModulePtr )> BuildSuccessCallback;
			typedef boost::function<void( ScriptModulePtr, const std::string& )> BuildErrorCallback;

		protected:
			RefPtr<Instance>		mInstance;
			ScriptEnginePtr			mEngine;
			BuildSuccessCallback	mSuccess;
			BuildErrorCallback		mError;

		public:
			ScriptCompiler( InstancePtr inst);
			virtual ~ScriptCompiler();
			
			const ScriptEnginePtr& getEngine() const;
			
			LoggerPtr getLog();

			void setBuildSuccessCallback( BuildSuccessCallback cbk ){ mSuccess = cbk; }
			void setBuildErrorCallback( BuildErrorCallback cbk ){ mError = cbk; }
			
			const InstancePtr& getInstance() const;
			InstancePtr& getInstance();
			

			void compile( ScriptModulePtr module, ScriptEditorWidgetPtr edit, bool throww = false );
			void compile( ScriptModulePtr module, const std::vector<ScriptEditorWidgetPtr>& edit, bool throww=false );

			void run( const std::string &module_name, const std::string &entry_point, ScriptEditorWidgetPtr edit );
			void run( const std::string &module_name, const std::string &entry_point, const std::vector<ScriptEditorWidgetPtr>& edit );
		};
	};
};

#endif